﻿using System;

namespace EnumApplication
{
    enum Gender
    {
        Male = 1,
        Female = 0
    }
    class Program
    {
        static void Main(string[] args)
        {
            Gender gender = Gender.Male;
            // Enum => int
            int genderId = (int)gender; // 1
            // int => Enum
            Gender gender1 = (Gender)0; // Female,超过枚举数值范围返回数值本身
            // Enum => string
            string genderStr = gender.ToString(); // Male
            // string => Enum
            Gender gender2 = (Gender)Enum.Parse(typeof(Gender), "Female"); // Gender.Female,超过字符串范围报错
        }
    }
}